/**
 * Created by 尼恩 at 疯狂创客圈
 */

package com.cheng.im.client.protoBuilder;


import com.cheng.im.client.session.ClientSession;
import com.cheng.im.common.bean.UserDTO;
import com.cheng.im.common.bean.msg.ProtoMsgV1;

/**
 * 心跳消息Builder
 */
public class HeartBeatMsgBuilder extends BaseBuilder
{
    private final UserDTO user;

    public HeartBeatMsgBuilder(UserDTO user, ClientSession session)
    {
        super(ProtoMsgV1.HeadType.HEART_BEAT, session);
        this.user = user;
    }

    public ProtoMsgV1.Message buildMsg()
    {
        ProtoMsgV1.Message message = buildCommon(-1);
        ProtoMsgV1.MessageHeartBeat.Builder lb =
                ProtoMsgV1.MessageHeartBeat.newBuilder()
                        .setSeq(0)
                        .setExtra("{\"from\":\"client\"}")
                        .setUid(user.getUserId());
        return message.toBuilder().setHeartBeat(lb).build();
    }


}


